<template>
  <div class="app-container">
    <!-- 优化后的导航栏 -->
    <div class="nav-container">
      <div class="logo-box" @click="$router.push('/')">
        <img src="http://www.zjjy.cc/img/logo1.1f6b24b9.png" alt="学校Logo" class="logo-img">
      </div>

      <el-menu 
        :default-active="activeIndex" 
        class="custom-nav-menu" 
        mode="horizontal" 
        @select="handleSelect"
        background-color="transparent" 
        text-color="#000" 
        active-text-color="#1890ff"
      >
        <el-menu-item index="1" @click="$router.push('/')">首页</el-menu-item>
        <el-menu-item index="2" @click="$router.push('/school')">学院简介</el-menu-item>
        <el-sub-menu index="3" popper-class="no-more-icon">
          <template #title>专业介绍</template>
          <el-menu-item index="3-1" @click="$router.push('/college/物联网学院')">物联网</el-menu-item>
          <el-menu-item index="3-2" @click="$router.push('/college/智能学院')">智能学院</el-menu-item>
          <el-menu-item index="3-3" @click="$router.push('/college/基础学院')">基础学院</el-menu-item>
          <el-menu-item index="3-4" @click="$router.push('/college/新媒体学院')">新媒体学院</el-menu-item>
        </el-sub-menu>
        <el-menu-item index="4">教学场景</el-menu-item>
        <el-menu-item index="5" @click="$router.push('/college/基础学院')">素质教育</el-menu-item>
        <el-menu-item index="6" @click="$router.push('/Employment')">就业喜报</el-menu-item>
      </el-menu>

      <div class="contact-info">
        <img src="https://www.pro-think.net/img/tel.png" alt="联系热线" class="contact-icon">
        <span class="contact-text">咨询热线: 13124408688</span>
      </div>
    </div>

    <!-- 轮播图 -->
    <div class="carousel-container">
      <el-carousel height="500px" motion-blur indicator-position="outside">
        <el-carousel-item v-for="(item, index) in banners" :key="index">
          <div class="carousel-item-container">
            <img :src="item.imageUrl" alt="知进学校宣传图" class="carousel-image">
            <div class="carousel-content">
              <h3 class="carousel-title">{{ item.title }}</h3>
              <p class="carousel-subtitle">{{ item.subtitle }}</p>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const router = useRouter();
const route = useRoute();
const activeIndex = ref('1');

// 根据当前路由设置激活菜单
const setActiveIndex = () => {
  const path = route.path;
  if (path === '/') activeIndex.value = '1';
  else if (path === '/school') activeIndex.value = '2';
  else if (path.includes('/college/物联网学院')) activeIndex.value = '3-1';
  else if (path.includes('/college/智能学院')) activeIndex.value = '3-2';
  else if (path.includes('/college/基础学院')) activeIndex.value = '3-3';
  else if (path.includes('/college/新媒体学院')) activeIndex.value = '3-4';
  else if (path === '/Employment') activeIndex.value = '6';
  else activeIndex.value = '';
};

// 初始化设置
setActiveIndex();

// 监听路由变化
watch(() => route.path, () => {
  setActiveIndex();
});

const handleSelect = (key: string) => {
  activeIndex.value = key;
};

const banners = ref([
  {
    imageUrl: 'http://www.zjjy.cc/img/banner2.a52d72ef.jpg',
    title: '知进学校 - 成就未来',
    subtitle: '高端 / 前沿 / 赋能'
  },
  {
    imageUrl: 'http://www.zjjy.cc/img/banner1.77d6a28e.jpg',
    title: '专业教育平台',
    subtitle: '提供全方位学习体验'
  },
  {
    imageUrl: 'http://www.zjjy.cc/img/banner3.9621dfcf.jpg',
    title: '创新教学模式',
    subtitle: '培养未来领袖'
  }
]);
</script>

<style scoped>
/* 全局容器 */
.app-container {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

/* 导航栏样式优化 */
.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 50px;
  height: 100px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
  max-width: 1600px;
  margin: 0 auto;
}

.logo-box {
  margin-right: 100px;
}

.logo-img {
  height: 80px;
  width: auto;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.logo-img:hover {
  transform: scale(1.05);
}

.custom-nav-menu {
  font-size: 18px;
  font-weight: 600;
  border: none;
  flex: 1;
}

/* 增强选中状态 */
.el-menu-item.is-active {
  position: relative;
  color: #1890ff !important;
  font-weight: bold;
}

.el-menu-item.is-active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background-color: #1890ff;
  border-radius: 3px;
  transition: all 0.3s;
}

.el-sub-menu.is-active .el-sub-menu__title {
  color: #1890ff !important;
}

/* 联系信息样式 */
.contact-info {
  display: flex;
  align-items: center;
  margin-left: 40px;
  font-size: 16px;
  color: #333;
}

.contact-icon {
  width: 24px;
  height: 24px;
  margin-right: 10px;
}

.contact-text {
  font-weight: 600;
  white-space: nowrap;
}
.carousel-container {
  width: 100%;
  overflow: hidden;
  margin-top: 0;
  max-width: 1461px;
  margin: 0 auto;
  padding: 0 30px;
}

.carousel-item-container {
  position: relative;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
/* 轮播图样式 */
.carousel-container {
  width: 100%;
  overflow: hidden;
  margin-top: 0;
  max-width: 1461px;
  margin: 0 auto;
  padding: 0 30px;
}

/* 其他原有样式保持不变... */
</style>

<style>
/* 全局样式 - 移除子菜单箭头 */
.no-more-icon .el-sub-menu__icon-arrow {
  display: none !important;
}
</style>